<?php 
	if (!is_dir('tmp')) {
		mkdir('tmp');
	} 
  	$text = html_entity_decode( urldecode( $_POST['content']  ) ); 
  	  
  	
	$datei_handle = fopen( 'tmp/'.$_POST['name'], 'a+') or die('fopen fehler');
	fwrite($datei_handle, $text ) or die('fwrite fehler');
	fclose($datei_handle) or die('fclose fehler');
	 
	header("Content-type: application/force-download; charset=utf-8");
	header("Content-Description: File Transfer");
	header("Content-Disposition: attachment; filename=".$_POST['name']);
	readfile('tmp/'.$_POST['name']); 
	unlink('tmp/'.$_POST['name']);
  
?>